 /**
  ********************************************
  Tree-Node class
  ********************************************
  
 * This program uses "Node" in conjucation with "StorageTree" for Homework 4
 * 
 * This class comes with a "remove" method on top of what was already here
 * 
 * @author (Greg Shevach & Chris Nerf) 
 * @version (0)
 * @date (11/6/2011)
 */

public class Node<T> {

	//variable declarations
    private T data;
    //counts the total number of elements of type T
    private int TCount = 0;
    //values less than current node
    private Node<T> nextLeft;
    //values greater than current node
    private Node<T> nextRight;

    //constructor with null or 0 values
    public Node() {
	data = null;
	TCount = 0;
	nextLeft = null;
	nextRight = null;
    }

    //constructor with a value
    public Node( T element ) {
	data = element;
	TCount+=1;
	nextLeft = null;
	nextRight = null;
    }
    
    // returns reference to the next left object
    public Node<T> getNextLeft()
    {
	return ( nextLeft );
    }
    
    //returns reference to the next right object
    public Node<T> getNextRight() {
	return ( nextRight );
    }

    //sets the value of the next left node
    public void setNextLeft( Node<T> node ) {
	nextLeft = node;
    }
    
    //sets the value of the next right node
    public void setNextRight( Node<T> node ) {
    	nextRight = node;
        }
    
    //gets the element value
    public T getElement() {
	return ( data );
    }
    
    //returns the total number of elements
    public int getElementCount() {
    	return ( TCount );
        }

    //sets the value of this node to element of type T
    public void setElement( T element ) {
	data = element;
    }
    
    //Increases the count of element of type T at the value of this node
    public void incrementTCount ()
    {
    	++TCount;
    }

    public String toString() {

	return ( data.toString() );
    }
 
    //this just removes the node
    //TODO: figure out what to do with children nodes
    public void remove(T element) {  //Sets the element equal to null
    data = element;
    data = null;
  }
}

